proc ifadmin {from} {
global admins mucinfo bot

set frm "[user_from_jid [string tolower $from]]"
	if {"$frm"== $bot(admin)} {
		putlog "OWNER ROSTER"
		return 6
	} elseif {[lsearch -exact $admins "$frm"]!=-1} {
		putlog "ADMIN ROSTER"
		return 5
	}

	#putlog "from==$from"
	if {"[info exists mucinfo(jid,$from)]"=="1"} {
		set jid [lindex [bot:splitjid $mucinfo(jid,$from)] 0]
		if {"$jid"=="$bot(admin)"} {
			putlog "OWNER MUC"
			return 6
		} elseif {[lsearch -exact $admins "$jid"]!=-1} {
			putlog "ADMIN MUC"
			return 5
		}
	} elseif { [info exists mucinfo(af,$from)]==1 } {
		if {$mucinfo(af,$from)=="member"} {
			putlog "member GROUPCHAT"
			return 1
		} elseif {$mucinfo(af,$from)=="admin" } {
			putlog "admin GROUPCHAT"
			return 3
		} elseif {$mucinfo(af,$from)=="owner"} {
			putlog "owner GROUPCHAT"
			return 4
		}
	} elseif {[info exists mucinfo(role,$from)]!=0} {
		if {$mucinfo(role,$from)=="moderator"} {
			putlog "moder GROUPCHAT"
			return 2
		} elseif {$mucinfo(role,$from)=="none"} {
			putlog "participant GROUPCHAT"
			return 0
		}
	}

	putlog "NNOO OONNEE"
	return 0
}

proc curtime {} {
	return [clock seconds]
}

proc cmd {text c} {
	if {[string range $text 0 [expr [string length $c]-1]]=="$c"} {
		return 1
	} else {return 0}
}

proc lview {body type conf serv nick} {
global txtedit
putlog $txtedit
set leng [string length $body]
putlog $leng
set num [string range $body 6 $leng]
putlog $num
set answ [lindex $txtedit $num]
	if {$type=="chat"} {
		pmsg "$conf" "$serv" "$nick" "$answ"
	} else {
		gmsg "$conf" "$serv" "$nick" "$answ"
	}
}


#from tkabber
proc user_from_jid {jid} {
    set user $jid
    regexp {(.*@.*)/.*} $jid temp user

    return $user
}
#from tkabber
proc node_and_server_from_jid {jid} {
    set nas $jid
    regexp {([^/]*)/.*} $jid temp nas

    return $nas
}
#from tkabber
proc server_from_jid {jid} {
    set serv $jid
    regexp {([^/]*)/.*} $jid temp serv
    regexp {[^@]*@(.*)} $serv temp serv

    return $serv
}
#from tkabber
proc resource_from_jid {jid} {
    set resource ""
    regexp {[^/]*/(.*)} $jid temp resource

    return $resource
}
#from tkabber
proc node_from_jid {jid} {
    set node ""
    regexp {^([^@/]*)@.*} $jid temp node

    return $node
}
#from tkabber
proc tolower_node_and_domain {jid} {
    
set nas [string tolower [node_and_server_from_jid $jid]]
	set resource [resource_from_jid $jid]

	if {![cequal $resource ""]} {
		return $nas/$resource
	} else {
		return $nas
	}
}


proc cequal {string1 string2} {
    if {[string compare $string1 $string2]} {
        return 0
    }

    return 1
}